
package com.trydofor.id.core;

import javax.annotation.Nonnull;

import com.trydofor.id.a9cq.A9cqMaker;
import com.trydofor.id.a9cq.AgentIntegerA9cq;
import com.trydofor.id.a9cq.FixedLongA9cq;
import com.trydofor.id.a9ic.A9IC;
import com.trydofor.id.a9ic.A9icAbstractMaker;
import com.trydofor.id.a9ic.A9icMixedMaker;
import com.trydofor.id.a9id.A9ID;
import com.trydofor.id.a9id.A9idAbstractMaker;
import com.trydofor.id.a9id.A9idMixedMaker;

/**
 * @author : Shi Rongjiu (www.trydofor.com)
 * @since 0.9.4
 */
public final class A9Makers {
    
    private A9Makers() {
        
    }
    
    /**
     * get a default long a9cq (1,1,Long.MAX_VALUE).
     * 
     * @return @Nonnull a9cq maker
     */
    @Nonnull
    public static A9Maker<Long> defaultA9cqLongMaker(int worker) {
        return new A9cqMaker<Long>(new FixedLongA9cq(false, 1, Long.MAX_VALUE, 1));
    }
    
    /**
     * get a default a9ic maker.
     * 
     * @see FixedLongA9cq
     * @see A9icAbstractMaker#SERIAL_STARTWITH
     * @see A9icAbstractMaker#SERIAL_INCREMENT
     * @see A9IC#getRangeOfSerial()
     * @param worker the worker
     * @return @Nonnull a9ic maker
     */
    @Nonnull
    public static A9Maker<A9IC> defaultA9icMaker(int worker) {
        long maxSerial = A9IC.getRangeOfSerial().maximum();
        long minSerial = A9icAbstractMaker.SERIAL_STARTWITH;
        int increment = A9icAbstractMaker.SERIAL_INCREMENT;
        FixedLongA9cq a9cq = new FixedLongA9cq(false, minSerial, maxSerial, increment);
        
        return new A9icMixedMaker(worker, a9cq);
    }
    
    /**
     * get a default second-based a9id maker.
     * 
     * @see FixedLongA9cq
     * @see A9idAbstractMaker#SECOND_BASEEPOCH
     * @see A9idAbstractMaker#SERIAL_STARTWITH
     * @see A9idAbstractMaker#SERIAL_INCREMENT
     * @see A9ID#getRangeOfSerial()
     * @param worker the worker
     * @return @Nonnull a9id maker
     */
    @Nonnull
    public static A9Maker<A9ID> defaultA9idSecondMaker(int worker) {
        long maxSerial = A9ID.getRangeOfSerial().maximum();
        long baseepoch = A9idAbstractMaker.SECOND_BASEEPOCH;
        long minSerial = A9idAbstractMaker.SERIAL_STARTWITH;
        int increment = A9idAbstractMaker.SERIAL_INCREMENT;
        FixedLongA9cq a9cq = new FixedLongA9cq(false, minSerial, maxSerial, increment);
        
        return new A9idMixedMaker(worker, baseepoch, AgentIntegerA9cq.wrap(a9cq), true);
    }
    
    /**
     * get a default serial-based a9id maker.
     * 
     * @see FixedLongA9cq
     * @see A9idAbstractMaker#SECOND_BASEEPOCH
     * @see A9idAbstractMaker#SERIAL_STARTWITH
     * @see A9idAbstractMaker#SERIAL_INCREMENT
     * @see A9ID#getRangeOfSerial()
     * @param worker the worker
     * @return @Nonnull a9id maker
     */
    @Nonnull
    public static A9Maker<A9ID> defaultA9idSerialMaker(int worker) {
        long maxSerial = A9ID.getRangeOfSerial().maximum();
        long baseepoch = A9idAbstractMaker.SECOND_BASEEPOCH;
        long minSerial = A9idAbstractMaker.SERIAL_STARTWITH;
        int increment = A9idAbstractMaker.SERIAL_INCREMENT;
        FixedLongA9cq a9cq = new FixedLongA9cq(false, minSerial, maxSerial, increment);
        
        return new A9idMixedMaker(worker, baseepoch, AgentIntegerA9cq.wrap(a9cq), false);
    }
}
